package com.yanfan.protocol.serialPort.serialPort;



import lombok.extern.slf4j.Slf4j;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 *  蚂蚁舞
 */
@Slf4j
public class SerialPortCallback {

    public void dataAvailable() {
        try {
            //当前监听器监听到的串口返回数据 back
            byte[] back = SerialPortManager.readSerialPortData();
            log.info("back-"+(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()))+"--"+ConvertHexStrAndStrUtils.bytesToHexStr(back));
            //System.out.println("back-"+(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()))+"--"+ConvertHexStrAndStrUtils.bytesToHexStr(back));
            String s = ConvertHexStrAndStrUtils.bytesToHexStr(back);
            log.info("rev--data:"+s);
            //System.out.println("rev--data:"+s);
            //throw new Exception();
        } catch (Exception e) {
            System.out.println(e.toString());
        }
    }
}

